<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>B</title>
</head>
<body>
<!--<script>
  window.onmessage = function(e) {
    console.log(e.data) //我爱你
    e.source.postMessage('嗯嗯，a页面，我收到你的消息了', e.origin)
  }
</script>-->
<script>
  let socket = new WebSocket('ws://localhost:3000');
  socket.onopen = function () {
    socket.send('lwf');//向服务器发送数据
  }
  socket.onmessage = function (e) {
    console.log(e.data);//接收服务器返回的数据
  }
</script>
</body>
</html>
